package com.example.health.db

import android.content.Context
import android.database.DatabaseErrorHandler
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper

/*
 *  @项目名：  trunk
 *  @包名：    com.sunson.sst.db
 *  @文件名:   DBhelper
 *  @创建者:   ${小陈}
 *  @创建时间:  2018/12/25 13:37
 *  @描述：    TODO
 */
class DBhelper : SQLiteOpenHelper {

    constructor(context: Context, name: String, version: Int) : super(context, name, null, version) {}

    constructor(context: Context, name: String, factory: SQLiteDatabase.CursorFactory, version: Int, errorHandler: DatabaseErrorHandler) : super(context, name, factory, version, errorHandler) {}
    val CREATE_CONTACT= "CREATE TABLE IF NOT EXISTS contactInfo (id Integer primary key autoincrement,name Text,phone TEXT,contact_phone TEXT,address TEXT,iconurl,TEXT)"
    val CREATE_INDEX = "create unique index IF NOT EXISTS 'contactInfo_unique' on contactInfo(id,phone,contact_phone)"
    override fun onCreate(sqLiteDatabase: SQLiteDatabase) {
        sqLiteDatabase.execSQL(CREATE_CONTACT)
        sqLiteDatabase.execSQL(CREATE_INDEX)
    }

    override fun onUpgrade(sqLiteDatabase: SQLiteDatabase, oldVersion: Int, newVersion: Int) {

    }
}
